#define _CRT_SECURE_NO_WARNINGS 1
#include "string.h"
namespace wusaqi
{
	//string::string()
	//: _str(new char[1] {'\0'})
	//, _size(0)
	//,_capacity(0)
	//{}

	string::string(const char* str)
		:_size(strlen(str))
	{
		_capacity = _size;
		_str = new char[_size + 1];
		strcpy(_str, str);
	}

	string::~string()
	{
		delete[] _str;
		_str = nullptr;
		_size = _capacity = 0;
	}

	size_t string::size() const
	{
		return _size;
	}
	char& string::operator[](size_t i)
	{
		assert(i < _size);

		return(_str[i]);
	}
	const char& string::operator[](size_t i) const
	{
		assert(i < _size);

		return(_str[i]);
	}

	const char* string::c_str()
	{
		return _str;
	}
}